package com.taihua_tech.basic.util;

import java.util.Map;

import org.apache.commons.beanutils.BeanMap;
import org.apache.commons.beanutils.BeanUtils;

public class MyBeanUtil {
	 public static Object mapToObject(Map<String, Object> map, Class<?> beanClass) throws Exception {    
	        if (map == null)  
	            return null;  
	  
	        Object obj = beanClass.newInstance();  
	  
	         BeanUtils.populate(obj, map);  
	  
	        return obj;  
	    }    
	      
	    public static Map<?, ?> objectToMap(Object obj) {  
	        if(obj == null)  
	            return null;   
	  
	        return new  BeanMap(obj);  
	    }   
	    
	    public static DataParam objectToDataParam (Object obj){
	    	DataParam param=new DataParam();
	    	param.append(objectToMap( obj)); 
	    	return param;
	    }
	      
}
